﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ChequeCategory
{
    public partial class ChequeCategory : Form
    {
        public ChequeManagement.BLL.BLLChequeCategoryFactory BCCF;
        ChequeManagement.BLL.BLLChequeCategory obj;
        ChequeManagement.BLL.BLLBank bankobj = new ChequeManagement.BLL.BLLBank();
        DataTable DT;
        public ChequeCategory()
        {
            InitializeComponent();
            BCCF = new ChequeManagement.BLL.BLLChequeCategoryFactory();
           obj = new ChequeManagement.BLL.BLLChequeCategory();
            DT = new DataTable();
        }

        private void ChequeCategory_Load(object sender, EventArgs e)
        {
            //// TODO: This line of code loads data into the 'cmdbDataSet1.uspDrawerFetchAll' table. You can move, or remove it, as needed.
            //this.uspDrawerFetchAllTableAdapter.Fill(this.dataSet1);
            //// TODO: This line of code loads data into the 'cmdbDataSet.uspBankFetchAll' table. You can move, or remove it, as needed.
            //this.uspBankFetchAllTableAdapter.Fill(this.cmdbDataSet.uspBankFetchAll);
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            bankobj.BankName = comboBoxBankName.Text;
            //obj.ChequeCategoryID = Convert.ToInt64(textBoxChequeCategoryID.Text);
            obj.ChequeCategoryName = textBoxChequeCategoryName.Text;
            obj.BranchName = textBoxBranchName.Text;
            obj.AccountNo = Convert.ToInt64(textBoxAccountNo.Text);
            obj.PageCount = Convert.ToInt32(textBoxPageCount.Text);
            obj.FirstPageNo = Convert.ToInt64(textBoxFirstPageNo.Text);
           // BCCF.Edit(obj, int.Parse(ChequeCategoryID));
            //try
            //{
            //    if (dataGridView1.CurrentRow != null)
            //    {
            //        ChequeManagement.BLL.BLLChequeCategory chequeCategoryObj = new ChequeManagement.BLL.BLLChequeCategory();
            //        ChequeManagement.BLL.BLLBank bankObj = new ChequeManagement.BLL.BLLBank();

            //        chequeCategoryObj.BankID = (int)dataGridView1.CurrentRow.Cells["BankID"].Value;
            //        bankObj.BankName = comboBoxBankName.Text;
            //        chequeCategoryObj.ChequeCategoryID = Convert.ToInt64(textBoxChequeCategoryID.Text);
            //        chequeCategoryObj.ChequeCategoryName = textBoxChequeCategoryName.Text;
            //        chequeCategoryObj.BranchName = textBoxBranchName.Text;
            //        chequeCategoryObj.AccountNo = Convert.ToInt64(textBoxAccountNo.Text);
            //        chequeCategoryObj.FirstPageNo = Convert.ToInt64(textBoxFirstPageNo.Text);
            //        chequeCategoryObj.PageCount = Convert.ToInt32(textBoxPageCount.Text);

            //        ChequeManagement.BLL.BLLChequeCategoryFactory chequecategoryFactory = new ChequeManagement.BLL.BLLChequeCategoryFactory();
            //        //  chequecategoryFactory.Edit(chequeCategoryObj, chequeCategoryObj.ChequeCategoryID);
            //    }
            //    else if (textBoxChequeCategoryID.Text != "")
            //    {
            //        ChequeManagement.BLL.BLLChequeCategory chequeCategoryObj = new ChequeManagement.BLL.BLLChequeCategory();
            //        chequeCategoryObj.ChequeCategoryID = Convert.ToInt64(textBoxChequeCategoryID.Text);

            //        ChequeManagement.BLL.BLLChequeCategoryFactory chequecategoryFactory = new ChequeManagement.BLL.BLLChequeCategoryFactory();
            //        chequecategoryFactory.Add(chequeCategoryObj);
            //    }
            //    else
            //    {
            //        MessageBox.Show("لطفا شماره سریال دسته چک را وارد نمایید");
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void btnPreview_Click(object sender, EventArgs e)
        {
            bankobj.BankName = comboBoxBankName.Text;
           // obj.ChequeCategoryID = Convert.ToInt64(textBoxChequeCategoryID.Text);
            obj.ChequeCategoryName = textBoxChequeCategoryName.Text;
            obj.BranchName = textBoxBranchName.Text;
            obj.AccountNo = Convert.ToInt64( textBoxAccountNo.Text);
            obj.PageCount = Convert.ToInt32( textBoxPageCount.Text);
            obj.FirstPageNo = Convert.ToInt64(textBoxFirstPageNo.Text);
            
            BCCF.Add(obj);
            BCCF.GetAll(DT);
        }

        private void bindingSource1_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            {
               //BCCF.Remove(int.Parse(ID.Text));
            }
        }
    }
}
